package com.xinqing.test.LetCode;

import java.util.ArrayList;

/**
 * @Author:CHQ
 * @Date:2021/7/20 16:14
 * @Description
 */
public class PreorderTraversal {
    static ArrayList<Integer> list;
    public static void main(String args[]) {
        list=new ArrayList<>();
        TreeNode root=new TreeNode(1);
        TreeNode l=new TreeNode(2);
        TreeNode r=new TreeNode(3);
        root.left=l;
        root.right=r;
        test(root);

        for(int x:list){
            System.out.print(x+" ");
        }

    }
    public static void test(TreeNode root){
        if(root==null){
                return ;
        }
        list.add(root.val);
        test(root.left);
        test(root.right);
    }

}


